package com.muqi.app.qlearn.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.baidu.mapapi.map.Text;
import com.muqi.app.qlearn.modles.RecordDetailBean;
import com.muqi.app.qlearn.student.R;

import com.muqi.app.user.widget.CircularImageView;
import com.muqi.app.user.widget.SelectableRoundedImageView;
import com.muqi.app.utils.ChineseUtils;

public class RewardsAndMovableAdapter extends BaseAdapter {
	private Context context;
	private List<RecordDetailBean> listData;
    private OnNextArrow onNextArrow;
    


	public void setOnNextArrow(OnNextArrow onNextArrow) {
		this.onNextArrow = onNextArrow;
	}

	public RewardsAndMovableAdapter(Context context, List<RecordDetailBean> listData) {
		this.context = context;
		this.listData = listData;
	}

	@Override
	public int getCount() {
		return listData == null ? 10 : listData.size();
	}

	@Override
	public RecordDetailBean getItem(int position) {
		return listData.get(position);
	}
   
	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		ViewHolder holder;
		final RecordDetailBean itemInfo = listData.get(position);
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_rewardsandmovable_adaptert, null);
			holder.itemPic = (CircularImageView) convertView
					.findViewById(R.id.circularImage);
			holder.itemName = (TextView) convertView
					.findViewById(R.id.item_name);
			holder.itemGameName = (TextView) convertView
					.findViewById(R.id.item_game);
			holder.itemDes = (TextView) convertView
					.findViewById(R.id.item_persom_name);
			holder.itemNext = (RelativeLayout) convertView
					.findViewById(R.id.arrow);
			holder.itemSName = (TextView) convertView
					.findViewById(R.id.item_sname);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.itemDes.setText("");
		holder.itemGameName.setText("");
		holder.itemName.setText("");
		holder.itemPic.setImageDrawable(null);
		holder.itemSName.setText("");
	
		if("F1".equals(itemInfo.fname)){
			holder.itemPic.setImageResource(R.drawable.statisc_morals);
		}else if("F2".equals(itemInfo.fname)){
			holder.itemPic.setImageResource(R.drawable.statisc_know);
		}else if("F3".equals(itemInfo.fname)){
			holder.itemPic.setImageResource(R.drawable.statisc_sport);
		}else if("F4".equals(itemInfo.fname)){
			holder.itemPic.setImageResource(R.drawable.static_bet);
		}else if("F5".equals(itemInfo.fname)){
			holder.itemPic.setImageResource(R.drawable.statisc_labour);
		}
		holder.itemName.setText(ChineseUtils.getFquality(itemInfo.fname));
		holder.itemSName.setText(ChineseUtils.getSquality(itemInfo.fname, itemInfo.sname));
		holder.itemGameName.setText(itemInfo.classname);
		holder.itemDes.setText(itemInfo.content);
		/*if (itemInfo != null) {
			if ("s1".equals(itemInfo.sname)) {
				
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + " "
						+ itemInfo.tvalue[3]);
				holder.itemPic.setImageResource(R.drawable.move_commonweal);
			} else if ("s2".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));

				holder.itemDes.setText(itemInfo.classname + " "
						+ itemInfo.tvalue[5]);
				holder.itemPic.setImageResource(R.drawable.move_soci);
			} else if ("s3".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[5]);
				holder.itemPic.setImageResource(R.drawable.move_soci);

			} else if ("s4".equals(itemInfo.sname)) {

			} else if ("s5".equals(itemInfo.sname)) {

			} else if ("s6".equals(itemInfo.sname)) {

			} else if ("s7".equals(itemInfo.sname)) {

			} else if ("s8".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[3]);
				holder.itemPic.setImageResource(R.drawable.reward_science);
			} else if ("s9".equals(itemInfo.sname)) {

			} else if ("s10".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[3]);
				holder.itemPic.setImageResource(R.drawable.reward_sport);
			} else if ("s11".equals(itemInfo.sname)) {

			} else if ("s12".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname);
				holder.itemPic.setImageResource(R.drawable.reward_sport);
			} else if ("s13".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[2] + "-" + itemInfo.tvalue[3]);
				holder.itemPic.setImageResource(R.drawable.move_soci);
			} else if ("s14".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname);
				holder.itemPic.setImageResource(R.drawable.reward_art);
			} else if ("s15".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[2]);
				holder.itemPic.setImageResource(R.drawable.move_soci);
			} else if ("s16".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[8] + "-" + itemInfo.tvalue[9]);
				holder.itemPic.setImageResource(R.drawable.reward_science);
			} else if ("s17".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[2]);
				holder.itemPic.setImageResource(R.drawable.reward_science);
			} else if ("s18".equals(itemInfo.sname)) {
				holder.itemName.setText(itemInfo.content);
				holder.itemGameName.setText(ChineseUtils.getSquality(
						itemInfo.fname, itemInfo.sname));
				holder.itemDes.setText(itemInfo.classname + "  "
						+ itemInfo.tvalue[2]);
				holder.itemPic.setImageResource(R.drawable.move_discover);
			}
		}*/

		return convertView;
	}

	private class ViewHolder {
		CircularImageView itemPic;
		TextView itemName;
		TextView itemSName;
		TextView itemGameName;
		TextView itemDes;
		RelativeLayout itemNext;

	}
	public interface OnNextArrow{
		void onNextArrowClick(int position);
	}
}
